<%-- 
    Document   : index
    Created on : Jul 7, 2011, 1:23:40 AM
    Author     : Thanhluan216
--%>

<%@page import="server.process.ProcessBeanLocal"%>
<%@page import="server.entity.RegisteredUser"%>
<%@page import="server.entity.Photo"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<jsp:include page="header.jsp"></jsp:include>
<div id="main">
    <div id="slidebar">
        <div id="login">
            <jsp:include page="login.jsp"></jsp:include>
        </div>
        <div id="search">
            <jsp:include page="search.jsp"></jsp:include>
        </div>
        <div id="product">
            <jsp:include page="categorypanel.jsp"></jsp:include>
        </div>
    </div>
    <div id="content">
        Photo <a href="#">Photo Name</a> Upload by <a href="#">Uploader</a>
        <br/>
        <table border="0">
            <center>
                <%
                            Context ctx = new InitialContext();
                            ProcessBeanLocal local = (ProcessBeanLocal) ctx.lookup("ProcessLocalJNDI");
                            int photoID = Integer.parseInt(request.getParameter("id"));
                            Photo photo = local.searchbyID(photoID);
                            RegisteredUser registeredUser =null;
                            if (session.getAttribute("username") != null) {
                                registeredUser = local.findUserbyID(session.getAttribute("username").toString());
                            }

                %>
                <table border="0">
                    <tr>
                        <td colspan="3"><img src="<%=photo.getServerFile()%>" height="300" width="400"/><br/>Upload by <a href="#"></a> | Date upload: <%=photo.getUploaddate()%> | View: <%=photo.getViews()%> | Download <%=photo.getDownloads()%></td>
                    </tr>
                    <tr>
                        <td><a href="comment.jsp?id=<%=request.getParameter("id")%>&action=comment">Comment</a></td>
                        <td><a href="viewallcomment.jsp?id=<%=request.getParameter("id")%>&action=viewall">View All (6) comment</a></td>
                        <td><a href="doComment?id=<%=request.getParameter("id")%>&action=download">Download this photo</a></td>
                    </tr>
                </table>
            </center>
            <form action="doComment" method="POST">
                <input type="hidden" name="id" value="<%=request.getParameter("id")%>" />

                <tr>
                    <td>Username</td>
                    <td><%=(registeredUser==null?"Guest":registeredUser.getUsername())%></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Email*</td>
                    <td><input type="text" name="Email" value="<%=(registeredUser==null?"":registeredUser.getEmail())%>"/></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Comment</td>
                    <td><textarea name="commentContent" rows="5" cols="50" ></textarea></td>
                    <td></td>
                </tr>
                <tr>
                    <td><input type="submit" name="action" value="Add Comment"/></td>
                    <td></td>
                    <td></td>
                </tr>
            </form>
        </table>
    </div>
</div>
<div id="footer">

</div>
</div>
</body>
</html>
